/*
 * @Author: fengweicong 75202172+fengweicong@users.noreply.github.com
 * @Date: 2022-05-28 14:42:18
 * @LastEditors: fengweicong 75202172+fengweicong@users.noreply.github.com
 * @LastEditTime: 2022-06-17 16:22:15
 * @FilePath: \hotel-management-system2.0\src\api\api.js
 * @Description:
 * 
 * Copyright (c) 2022 by fengweicong 75202172+fengweicong@users.noreply.github.com, All Rights Reserved. 
 */
import axios from "./index.js"

/*******************************************/
/****************  账号api  ****************/
/*******************************************/
/**
 * @description: 获取所有账号
 * @param {*} return
 * @return {*} [{}]
 */
export function getAllUser() { return axios.get('user') }


/*******************************************/
/****************  房型api  ****************/
/*******************************************/
/**
 * @description: 获取所有房型
 * @param {*} return
 * @return {*} [{}]
 */
export function getAllRoomType() { return axios.get('room/type') }

/**
 * @description: 增加一个房型
 * @param {*} obj 房型对象 {"facility":"一张单床1.2m,30m²,含双早,12层,有窗,24h免费停车","price":399,"title":"单人大床房","tin":1,"isEdit":false,"imgUrl":"img/单人大床房.7119e3e8.webp"}
 * @return {*}
 */
export function addOneRoomType(obj) { return axios.post('room/type',obj) }

/**
 * @description: 修改一个房型
 * @param {*} item 房型对象 {"facility":"一张单床1.2m,30m²,含双早,12层,有窗,24h免费停车","price":399,"title":"单人大床房","tin":1,"isEdit":false,"imgUrl":"img/单人大床房.7119e3e8.webp"}
 * @return {*}
 */
export function modifyOneRoomType(item) {
    return axios.post(`room/type/modify/${item.tin}`,{
    facility: item.facility, price: item.price, title: item.title, tin: item.tin
}) }

/**
 * @description: 删除一个房型
 * @param {*} tin 房型id
 * @return {*}
 */
export function deleteOneRoomType(tin) { return axios.post(`room/type/${tin}`) }



/*******************************************/
/****************  房间api  ****************/
/*******************************************/
/**
 * @description: 获取所有房间
 * @param {*} return
 * @return {*} [{}]
 */
export function getAllRoom() { return axios.get('room') }

/**
 * @description: 添加一个房间
 * @param {*} obj 房间对象 {"rin":1203,"rsin":0,"tin":1}
 * @return {*}
 */
export function addOneRoom(obj) { return axios.post('room', obj) }

/**
 * @description: 删除一个房间
 * @param {*} rin 房间id
 * @return {*}
 */
export function deleteOneRoom(rin) { return axios.post(`room/${rin}`) }

/**
 * @description: 修改一个房间的状态
 * @param {*} rin 房间id
 * @param {*} obj 房间对象 {"rin":1203,"rsin":0,"tin":1}
 * @return {*}
 */
export function modifyOneRoomState(rin, obj) { return axios.post(`room/modify/${rin}`, obj) }

/**
 * @description: 获取所有可使用房间
 * @param {*} return
 * @return {*} [{}]
 */
export function getAllUnuseRoom() { return axios.get('room/unused')}



/*******************************************/
/****************  预订单api  ****************/
/*******************************************/
/**
 * @description: 获取所有预订单
 * @param {*} return
 * @return {*} [{}]
 */
export function getAllBookOrder() { return axios.get('orderbook') }

/**
 * @description: 通过OCIN添加房客记录
 * @param {*} obj 房客对象 { roomerName: row.roomerName, roomerID: row.roomerID, ocin: 1}
 * @return {*}
 */
export function addOneCustomerInBookOrder(obj) { return axios.post('ordercheck/roomer', obj) }

/**
 * @description: 增加一条预订单
 * @param {*} obj 预订单对象
 * {
 *       "checkInTime": "2020-02-04T18:00:00.000+0000",
 *       "checkOutTime": "2020-02-05T18:00:00.000+0000",
 *       "discount": null,
 *       "finalPrice": null,
 *       "orderTime": "2020-02-02T18:00:00.000+0000",
 *       "roomPrice": null,
 *       "roomTypeTitle": "总统套房",
 *       "roomerID": "123456789",
 *       "roomerName": "Ray",
 *       "roomerPhone": "16606660777",
 *       "vipLevel": null,
 *       "obin": 20,
 *       "bsin": 10
 *  }
 * @return {*}
 */
export function addOneBookOrder(obj) { return axios.post('orderbook',obj)}

/**
 * @description: 删除一条预订单
 * @param {*} obin 预订单id
 * @return {*}
 */ 
export function deleteOneBookOrder(obin) { return axios.post(`orderbook/${obin}`)}

/**
 * @description: 修改一条预订单
 * @param {*} obin 预订单id
 * @param {*} obj 预订单对象
 *  * {
 *       "checkInTime": "2020-02-04T18:00:00.000+0000",
 *       "checkOutTime": "2020-02-05T18:00:00.000+0000",
 *       "discount": null,
 *       "finalPrice": null,
 *       "orderTime": "2020-02-02T18:00:00.000+0000",
 *       "roomPrice": null,
 *       "roomTypeTitle": "总统套房",
 *       "roomerID": "123456789",
 *       "roomerName": "Ray",
 *       "roomerPhone": "16606660777",
 *       "vipLevel": null,
 *       "obin": 20,
 *       "bsin": 10
 *  }
 * @return {*}
 */
export function modifyOneBookOrder(obin, obj) { return axios.post(`orderbook/modify/${obin}`, obj)}
        


/*******************************************/
/****************  入住订单api  ****************/
/*******************************************/
/**
 * @description: 获取所有入住订单
 * @param {*} return
 * @return {*} [{}]
 */
export function getAllCheckInOrder() { return axios.get('ordercheck') }

/**
 * @description: 增加一条入住订单
 * @param {*} obj 入住订单对象 
 * {
 *       "orderTime": null,
 *       "checkInTime":"",
 *       "checkOutTime":"",
 *       "roomTypeTitle":"",
 *      "roomPlate":"",
 *       "roomPrice":0,
 *       "vipLevel":0,
 *       "discount":1,
 *       "finalPrice": 0,
 *       "obin":null,
 *       "ocin":40,
 *       "csin":1,
 *       "ocin":40,
 *       "vip":''
 * },
 * @return {*}
 */
export function addOneCheckInOrder(obj) { return axios.post('ordercheck', obj)}

/**
 * @description: 在入住订单增加一条房客信息
 * @param {*} obj 房客对象 {"roomerName":"","roomerID":"","ocin":-1}
 * @return {*}
 */
export function addOneCustomerInCheckInOrder(obj) { return axios.post('ordercheck/roomer', obj)}

/**
 * @description: 修改一条入住订单信息
 * @param {*} obin 订单id
 * {
 *       "orderTime": null,
 *       "checkInTime":"",
 *       "checkOutTime":"",
 *       "roomTypeTitle":"",
 *      "roomPlate":"",
 *       "roomPrice":0,
 *       "vipLevel":0,
 *       "discount":1,
 *       "finalPrice": 0,
 *       "obin":null,
 *       "ocin":40,
 *       "csin":1,
 *       "ocin":40,
 *       "vip":''
 * },
 * @return {*}
 */
export function modifyOneCheckInOrder(obin,obj) { return axios.post(`ordercheck/modify/${obin}`, obj)}





/*******************************************/
/****************  VIP api  ****************/
/*******************************************/
/**
 * @description: 获取一条vip的新
 * @param {*} vip vip的id
 * @return {*}
 */
export function getOneVip(vip) { return axios.get(`VIP/${vip}`)}

/**
 * @description: 获取所有vip信息
 * @param {*} return
 * @return {*}
 */
export function getAllVip() { return axios.get('VIP')}

/**
 * @description: 增加一个会员
 * @param {*} obj 会员对象{"name": this.newName, "points": 0,  "vip": this.newVip, "lv": 0,  "id": this.newID}
 * @return {*}
 */
export function addOneVip(obj) { return axios.post('VIP', obj)}

/**
 * @description: 删除一个会员
 * @param {*} vip 会员id
 * @return {*}
 */
export function deleteOneVip(vip) { return axios.post(`VIP/${vip}`)}

/**
 * @description: 修改一条Vip信息
 * @param {*} vip vip的id
 * @param {*} obj vip对象
 * @return {*} 
 */
export function modifyOneVip(vip, obj) { return axios.post(`VIP/modify/${vip}`, obj)}



/*******************************************/
/****************  roomer api  ****************/
/*******************************************/
/**
 * @description: 获取一条入住订单的所有房客
 * @param {*} ocin 入住订单id
 * @return {*} {}
 */
export function getAllCustomersInCheckIiOrder(ocin) { return axios.get(`roomer/${ocin}`)}



/*******************************************/
/****************  商品 api  ****************/
/*******************************************/
/**
 * @description: 获取所有商品
 * @param {*} return
 * @return {*} [{}]
 */
export function getAllGoods() { return axios.get('good') }

/**
 * @description: 修改一种商品价格
 * @param {*} gin 商品id
 * @param {*} obj 商品对象 { "inventory": row.inventory, "price": row.input, "title": row.title, "gin": row.gin}
 * @return {*} 
 */
export function modifyOneGoods(gin, obj) { return axios.post(`good/modify/${gin}`, obj) }

/**
 * @description: 增加一种商品
 * @param {*} obj 商品对象 { "inventory": 10, "price": 3, "title": "可口可乐12", "gin": gin}
 * @return {*}
 */
export function addOneGoods(obj) { return axios.post('good', obj)}

/**
 * @description: 删除一种商品
 * @param {*} gin 商品id
 * @return {*} 
 */
export function deleteOneGoods(gin) { return axios.post(`goods/${gin}`)}

/**
 * @description: 获取所有商品订单
 * @param {*} return
 * @return {*} [{}]
 */
export function getAllSaleOrder() { return axios.get('good/sales')}

/**
 * @description: 获取所有进货订单
 * @param {*} return
 * @return {*} [{}]
 */
export function getAllRestockOrder() { return axios.get('orderrestock')}

/**
 * @description: 增加一条进货信息
 * @param {*} obj
 * {
        "amount": this.newGoodNumber * 1,
        "goodPrice": this.newGoodPrice * 1.0,
        "goodTitle": this.newGoodName,
        "orderTime": this.returnNowTime(),
        "totalPrice": this.newGoodNumber * this.newGoodPrice,
        "orin": this.restockOrders[this.restockOrders.length - 1].orin
      }
 * @return {*}
 */
export function addOneRestockOrder(obj) { return axios.post('orderrestock', obj)}



/*******************************************/
/****************  营业信息 api  ****************/
/*******************************************/
/**
 * @description: 获取入住今日收入
 * @param {*} return
 * @return {*} Number
 */
export function getC1D1() { return axios.get('view/room/today')}

/**
 * @description: 获取入住昨日收入
 * @param {*} return
 * @return {*} Number
 */
export function getC1D2() { return axios.get('view/room/yesterday')}

/**
 * @description: 获取入住本月收入
 * @param {*} return
 * @return {*} Number
 */
export function getC1D3() { return axios.get('view/room/month')}

/**
 * @description: 获取入住全部收入
 * @param {*} return
 * @return {*} Number
 */
export function getC1D4() { return axios.get('view/room')}

/**
 * @description: 获取商品今日收入
 * @param {*} return
 * @return {*} Number
 */
export function getC2D1() { return axios.get('view/sale/today')}

/**
 * @description: 获取商品昨日收入
 * @param {*} return
 * @return {*} Number
 */
export function getC2D2() { return axios.get('view/sale/yesterday')}

/**
 * @description: 获取商品本月收入
 * @param {*} return
 * @return {*} Number
 */
export function getC2D3() { return axios.get('view/sale/month')}

/** 
 * @description: 获取商品全部收入
 * @param {*} return
 * @return {*} Number
 */
export function getC2D4() { return axios.get('view/sale')}

/**
 * @description: 获取总支出
 * @param {*} return
 * @return {*} Number
 */
export function getC3D1() { return axios.get('view/saleE')}

/** 
 * @description: 获取总收入
 * @param {*} return
 * @return {*} Number
 */
export function getC3D2() { return axios.get('view/saleE')}
